#include <bits/stdc++.h>
using namespace std;

class Solution {
   public:
    int maximumNumberOfStringPairs(vector<string>& words) {
        int ret = 0;
        unordered_set<string> m;
        for (int i = 0; i < words.size(); ++i) {
            string tmp(words[i].size(), 0);
            reverse_copy(words[i].begin(), words[i].end(), tmp.begin());
            if (m.find(tmp) != m.end()){
                ++ret;
            }
            else {
                m.insert(words[i]);
            }
        }
        return ret;
    }
};